/* Wang Wen(Albert Wang) jawangwen@gmail.com */

#ifndef __RT_STUB_H__
#define __RT_STUB_H__

#ifdef __cplusplus
extern "C" {
#endif

#include <assert.h>
#include "rt_debug.h"

#define SET_STUB(func, stub) do {                       \
    RT_STUB_TRACE("[set_stub] <%s:0x%x> => <%s:0x%x>",  \
                  #func,                                \
                  (unsigned int)(func),                 \
                  #stub,                                \
                  (unsigned int)(stub));                \
    assert(!set_stub((void *)(func), (void *)(stub)));  \
} while (0)

#define DEL_STUB(func) do {                 \
    RT_STUB_TRACE("[del_stub] <%s:0x%x>",   \
                  #func,                    \
                  (unsigned int)(func));    \
    assert(!del_stub((void *)func));        \
} while (0)

#define CLEAN_STUB()  do {                  \
    RT_STUB_TRACE("[clean_stub] <all>");    \
    assert(!clean_stub());                  \
} while (0)

int set_stub   (void * func, void * stub);
int del_stub   (void * func);
int clean_stub (void);

#ifdef __cplusplus
}
#endif

#endif /* __RT_STUB_H__ */

